package com.demo.service;

import com.alibaba.dubbo.config.annotation.Service;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.demo.bean.Demo;
import com.demo.dao.DemoMapper;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.List;

/**
 * Created by lcs on 2018/9/26.
 */
@Service
@Transactional
public class DemoServiceImp implements DemoService {

	@Resource
	private DemoMapper demoMapper;

	@Override
	public Demo add(Demo demo) {
		this.demoMapper.insert(demo);
		return demo;
	}

	@Override
	public Demo get(Long id) {
		return this.demoMapper.selectById(id);
	}

	@Override
	public IPage<Demo>  getPage(int page,int pageSize){
		return this.demoMapper.selectPage(new Page<>(page,pageSize), new QueryWrapper<>());
	}

	@Override
	public List<String> getNames() {
		return this.demoMapper.getAllName();
	}
}
